package com.neuedu.thread;

/**
 * @author 金山
 * 项目：javase
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/10/3114:03
 */
public class MyRunnable  extends  Object  implements  Runnable{

    private String name;

    public MyRunnable(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        while (true){
            System.out.println( name+"线程在执行--在吃饭--Runnable");
            //让 线程休眠 一段事件
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }


    public static void main(String[] args) {

        //1 创建线程对象 （创建一个学生）
        MyRunnable myRunnable1 = new MyRunnable("1李四-");
        MyRunnable myRunnable2 = new MyRunnable("2王五--");
        MyRunnable myRunnable3 = new MyRunnable("3赵六---");


        //2 使用  Thread 包装一下 Runnable 类型的对象
        Thread thread1 = new Thread(myRunnable1);
        Thread thread2 = new Thread(myRunnable2);
        Thread thread3 = new Thread(myRunnable3);

        //3 启动（   排队等着打饭）
        thread1.start();
        thread2.start();
        thread3.start();

    }



}
